<template>
	<view class="content">
		<view class="title_div">
			修改密码
		</view>
	
		<view class="login_form" onsubmit="return false;">
			<view class="login_item">
				<input type="password" v-model="oldPwd" placeholder="请输入旧密码" />
			</view>
			<view class="login_item">
				<input type="password" v-model="newPwd" placeholder="请输入新密码" />
			</view>
			<view class="login_item">
				<input type="password" v-model="newPwd2" placeholder="请再次输入新密码" />
			</view>
	
			<button class="login_btn" @tap="pwdSub">确认修改</button>
	
		</view>
	
		
	</view>
</template>

<script>
	export default{
		data(){
			return{
				oldPwd:'',//旧密码
				newPwd:'',//新密码
				newPwd2:'',//再次输入新密码
			}
		},
		methods:{
			pwdSub:function(){
				if(this.oldPwd==''){
					uni.showToast({
						title:"请输入旧密码"
					});
					return;
				}
				
				if(this.newPwd==''){
					uni.showToast({
						title:"请输入新密码"
					});
					return;
				}
				
				if(this.newPwd2==''){
					uni.showToast({
						title:"请再次输入新密码"
					});
					return;
				}
				if(this.newPwd!=this.newPwd2){
					uni.showToast({
						title:"新密码不一致，请确认！"
					});
					return;
				}
				//提交新旧密码
				uni.request({
					url:this.baseUrl+'updatePwd',
					method:'POST',
					data:{
						'uid':uni.getStorageSync('uid'),
						'oldPwd':this.oldPwd,
						'newPwd':this.newPwd,
						'rePwd':this.newPwd2
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success:function(res){
						if(res.code==0){
							uni.showToast({
								title:"修改成功"
							});
							uni.navigateBack();
						}else{
							uni.showToast({
								title:"修改失败"
							});
						}
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #FFFFFF;
	}
	
	.title_div {
		height: 156rpx;
		line-height: 156rpx;
		padding-left: 50rpx;
		padding-right: 50rpx;
		font-size: 50rpx;
		color: #333333;
	}
	
	.login_form {}
	
	.login_form .login_item {
		margin-left: 50rpx;
		margin-right: 50rpx;
		height: 100rpx;
		border-bottom: 1px solid #E8E8E8;
	}
	
	.login_form .login_item input {
		height: 100rpx;
		font-size: 28rpx;
		color: #333333;
		padding-left: 30rpx;
		padding-right: 30rpx;
	
	}
	
	.login_btn {
		height: 88rpx;
		margin-left: 50rpx;
		margin-right: 50rpx;
		background: #e13b29;
		border-radius: 44rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		line-height: 88rpx;
		margin-top: 40rpx;
	}
	
	
</style>
